package lanqiao.dontaiguihua.dfs;

import java.util.Scanner;

//数字三角形
public class Lan505 {
    static int max=0;
    static int lmax=0;
    static int n;
    static int[][] a;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        a=new int[n+1][n+1];

        for(int i=1;i<=n;i++){
            for(int j=1;j<=i;j++){
                a[i][j]=sc.nextInt();
                a[i][j]=a[i][j]+Math.max(a[i-1][j],a[i-1][j-1]);
            }
        }
        if(n%2==0){
            System.out.println(Math.max(a[n][n/2],a[n][n/2+1]));

        }else{
            System.out.println(a[n][n/2+1]);
        }
        sc.close();
    }

}
